package com.design.observer.football;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xiemiao
 * @description
 * @date 2023/08/18
 */
public class ChiefCoach implements Coach {

    private String name;

    private List<Player> playerList = new ArrayList<>();

    public ChiefCoach(String name) {
        this.name = name;
    }

    @Override
    public void addPlayer(Player player) {
        playerList.add(player);
    }

    @Override
    public void removePlayer(Player player) {
        playerList.remove(player);
    }

    @Override
    public void notifyPlayer(String msg) {
        System.out.println(name + "发出了" + msg + "信号");
        for (Player player : playerList) {
            player.update(msg);
        }
    }
}
